package com.example.highperformanceandroidtech.fragment;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.graphics.drawable.RoundedBitmapDrawable;
import androidx.core.graphics.drawable.RoundedBitmapDrawableFactory;
import androidx.fragment.app.Fragment;

import com.example.highperformanceandroidtech.R;

public class Example1_4Fragment extends Fragment {
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_example1_4,container,false);
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        ImageView imageView1 = view.findViewById(R.id.imageView1);
        imageView1.setImageResource(R.mipmap.ic_vo);

        RoundedBitmapDrawable roundedDrawable = RoundedBitmapDrawableFactory.create(getResources(),
                BitmapFactory.decodeResource(getResources(),R.mipmap.ic_vo));
        roundedDrawable.getPaint().setAntiAlias(true);
        roundedDrawable.setCornerRadius(30);
        ImageView imageView2 = view.findViewById(R.id.imageView2);
        imageView2.setImageDrawable(roundedDrawable);

        Bitmap bitmap = BitmapFactory.decodeResource(getResources(),R.mipmap.ic_vo);
        RoundedBitmapDrawable circleDrawable = RoundedBitmapDrawableFactory.create(getResources(),
                BitmapFactory.decodeResource(getResources(),R.mipmap.ic_vo));
        circleDrawable.getPaint().setAntiAlias(true);
        circleDrawable.setCornerRadius(Math.max(bitmap.getWidth(),bitmap.getHeight()));
        ImageView imageView3 = view.findViewById(R.id.imageView3);
        imageView3.setImageDrawable(circleDrawable);


    }
}
